package com.app.web.sys.banner;

import com.app.utils.base.http.ResultUtil;
import com.app.utils.spring.properties.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 广告服务
 */
@RestController
@RequestMapping("/system/banner/")
public class BannerController {

    @Autowired
    private BannerManager bannerManager;

    /**
     * 广告列表接口
     * @param placeId 位置ID
     * @param app 端
     * @return
     */
    @ResponseBody
    @RequestMapping("list")
    public String list(@RequestParam(defaultValue = "0")int placeId, @RequestParam(defaultValue = "0") int app){
        //验证参数
        if(placeId<=0 || app <= 0){
            return ResultUtil.error("6001", Config.pp.get("6001"));
        }
        app = app > 5 ? 5 : app;
        //返回结果
        return ResultUtil.success(bannerManager.list(placeId,app));
    }

}
